package leetcode.biweekly.week101;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

//Solution1Test
public class Solution1 {
	public int minNumber(int[] nums1, int[] nums2) {
		Arrays.sort(nums1);
		Arrays.sort(nums2);
		Set<Integer> set = new HashSet<>();
		for (int num : nums1) {
			set.add(num);
		}
		for (int num : nums2) {
			if (set.contains(num)) {
				return num;
			}
		}
		int ans1 = nums1[0] * 10 + nums2[0];
		int ans2 = nums2[0] * 10 + nums1[0];
		return Math.min(ans1, ans2);
	}

}
